# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

a = Analysis(
    ['app.py'],
    pathex=[],
    binaries=[],
    datas=[('app', 'app')],  # 包含app目录
    hiddenimports=[
        'prophet', 
        'prophet.models', 
        'pystan', 
        'cmdstanpy',
        'pandas',
        'numpy',
        'matplotlib',
        'prophet.diagnostics',
        'prophet.plot',
        'holidays',
        'holidays.holiday_base',
        'holidays.utils',
        'stan_model',
        'matplotlib.backends.backend_agg'
    ],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)

# 添加Prophet库相关文件
import prophet
import os
import sys

prophet_dir = os.path.dirname(prophet.__file__)

# 正确格式为(源文件路径, 目标目录, 类型)，类型通常为'DATA'
extra_datas = []
for dirpath, dirnames, filenames in os.walk(prophet_dir):
    for filename in filenames:
        source_path = os.path.join(dirpath, filename)
        target_path = os.path.join('prophet', os.path.relpath(dirpath, os.path.dirname(prophet_dir)))
        extra_datas.append((source_path, target_path, 'DATA'))

# 将额外的数据文件添加到Analysis对象
a.datas.extend(extra_datas)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='app',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
